package com.test.t1;

import com.test.bean.Boss;
import com.test.bean.Color;
import com.test.config.MainConfigAutowire;
import com.test.service.BookService;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @author lzy
 * @version v1.0
 * Create DateTime: 2018/11/29 9:35
 */
public class IocTest_Autowire {
    @Test
    public void test01() {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(MainConfigAutowire.class);
        BookService service = context.getBean(BookService.class);
        System.out.println(service);
        service.print();

        Boss boss = context.getBean(Boss.class);
        System.out.println(boss);

        Color color = context.getBean(Color.class);
        System.out.println(color);

        context.close();
    }

    @Test
    public void test02() {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(MainConfigAutowire.class);
        context.close();
    }
}
